package com.longtop.leaning.ui;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import com.longtop.leaning.data.AppData;
import com.longtop.leaning.data.UIData;

public class ModeList extends List implements CommandListener{
	private static final String[] stringArray = { "在线模式", "离线模式" };
	
	public ModeList() {
		super("选择模式", Choice.IMPLICIT, stringArray, null);
		super.addCommand(UIData.CMD_EXIT);
		super.addCommand(UIData.CMD_OK);
		super.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if(c == UIData.CMD_OK || c == List.SELECT_COMMAND){
			AppData.isOnLine = ((List) d).getSelectedIndex() == 0;
			UIData.display.setCurrent(new LoginForm());
		}
		if (c == UIData.CMD_EXIT) {
			UIData.mainMIDlet.destroy(false);
			UIData.mainMIDlet.notifyDestroyed();
		}
		
	}

}
